package validation;

import dbmanager.DBManager;

public class Isalphabetic implements Validation
{

	boolean FLAG = false;
	String value;
	public boolean validate(String Value) 
	{
	   System.out.println(Value);
	   Value = Value.replace(" ", "");
		
		for(int i=0;i<Value.length();i++)
		{
			if(Value.charAt(i) == '.')
			{
				continue;
			}
			for(int j=65;j<=122;j++)
			{
				if (j==91)
					j=97;
				
				if(Value.charAt(i) == (char)j)
				{
					FLAG = true;
					break;
				}
				FLAG = false;
			}
			if(FLAG == false)
				return false;
		}
		return true;
	}
	
	public boolean validate(String Value, String conditionValue)
	{	
		return false;
	}
	public String getMessage()
	{
		return " must be alphabetic only not allowing:"+value;
	}
	
	public static void main(String[] args) 
	{
		// TODO Auto-generated method stub
		Isalphabetic ia = new Isalphabetic();
		
		System.out.println ("Is Valid  : "+ia.validate("gaseht.rt","",""));
		System.out.println ();
		
		System.out.println ("Is Valid  : "+ia.validate("7348asert","",""));
		System.out.println ();

		
		System.out.println ("Is Valid  : "+ia.validate("&$!#)#%&","",""));
		System.out.println ("Is Valid  : "+ia.validate("gaseht.rt", "false", "")); 
	}

	public void setDbmanager(DBManager database) 
	{
			
	}

	public boolean validate(String Value, String ConditionValue, String Refvalue) 
	{
		if(ConditionValue.equalsIgnoreCase("true"))
		{
			return validate(Value);
		}
		else if(ConditionValue.equalsIgnoreCase("false"))
		{
	    		return true;
		}
		else
		{
	    	 return false;
		}
			
	}

	public void setBasicvalue(String value)
	{
		this.value = value;
		
	}
}
